
$(document).ready(function(){
	var rootPath = getRootPath();
	var carOwnerUserId = getQueryParamValue("carOwnerUserId");
	
	$.ajax({
		method : 'get',
		url : rootPath+'/wechat/api/maintain/rescues?carOwnerUserId='+carOwnerUserId,
		error:function(XMLHttpRequest, ajaxOptions, thrownError){
			alert("连接服务器错误!");
		},
		success : function(resultData){
			
			var wholeHtml = '';
			
			$.each(resultData,function(sosHelpIndex,sosHelpObj){
				
				var sosHelpHtml = '';
				
				var supportDate = "";
				
				var createDate = "";
				
				var soshelpId = sosHelpObj.soshelpId
				
				if(sosHelpObj.status=='待救援'||sosHelpObj.status=='救援中'){
					color = 'F6304F';
				}else if(sosHelpObj.status=='已救援'){
					color = '48ACED';
				}else{
					color = 'C0C0C0';
				}
				if(sosHelpObj.supportDate == null){
					supportDate = " ";
				}else{
					supportDate = sosHelpObj.supportDate 
				}
				if(sosHelpObj.createDate == null){
					createDate = " ";
				}else{
					createDate = sosHelpObj.createDate 
				}
				
				sosHelpHtml = sosHelpHtml 	+ '<div class="panel panel-default">'
											+ 	'<a href="soshelpinfor.html?soshelpId='+soshelpId+'&carOwnerUserId='+carOwnerUserId+'" class="list-group-item clearfix">'
											+ 	  '<div style="width:70%;float:left">'
											+ 	    '<p style="font-family:黑体;font-size:15px">'
											+		  '救援位置：<span>'+ sosHelpObj.helpLocal +'</span>'
											+ 		'</p>'
											+		  '<div style="width:140%;height:1px;margin:0px auto;padding:0px;background-color:#E7E7E7;overflow:hidden;"></div>'
				  							+ 	  '</div>'
											+ 	  '<div style="width:20%;float:right">'
											+ 	    '<span style="float:right" class="glyphicon glyphicon-chevron-right"></span>'
											+ 	  '</div>'
											+ 	  '<div style="width:70%;float:left">'
			  								+		'<p>'
			  								+		  '<small style="color:#C0C0C0">请求时间：'+ createDate +'</small>'
			  								+		'</p>'
			  								+		'<p>'
			  								+		  '<small style="color:#C0C0C0">救援时间：'+ supportDate +'</small>'
			  								+		'</p>'
			  								+	  '</div>'
											+ 	  '<div style="width:20%;float:right">'
											+	  '<p></p><br>'
											+	  '<p>'
											+	    '<span style="float:right;font-family:黑体;color:#'+ color +'">'+ sosHelpObj.status + '</span>'
											+	  '</p>'
											+	 '</div>'
											+ 	'</a>'
											+ '</div>'
				
				wholeHtml += sosHelpHtml;
			});
			
			$("#all").append(wholeHtml);
		}
	});
})
